from appuifw import app
from e32 import drive_list,start_exe
from os import path as ospath
from codecs import open as openfile
from struct import unpack
from sys import path as syspath

__appname__=u'NetAlarm'
nomeeseguibileserver = 'netalarm_server_0xeaea0000.exe'
settingsfile=u'c:\\data\\others\\%s.cfg'% __appname__
numerotacche=1
numerointervallo=30
autostart=1
inferiore=0
fid=0

def carica_settings():
	global numerotacche,numerointervallo,autostart
	if ospath.exists(settingsfile):
		readsettings=openfile(settingsfile,'rb').readlines()[0]
		try: numerotacche,numerointervallo,autostart=unpack('>hhh',readsettings)
		except: pass

def dmn_start(silent=0):
	drives=drive_list()
	percorso=u'\\sys\\bin\\%s'%(nomeeseguibileserver)
	for d in drives:
		try: start_exe(u'%s%s'%(d,percorso),'')
		except: continue

try: app.orientation='portrait'
except: pass
carica_settings()
if autostart: dmn_start(silent=1)
app.set_exit()